package com.sikadwafastdaisfondturbo.pretloan.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.sikadwafastdaisfondturbo.lib_baseadapter.SikadwaRecyclerViewAdapter
import com.sikadwafastdaisfondturbo.lib_baseadapter.SikadwaViewHolderHelper
import com.sikadwafastdaisfondturbo.pretloan.R
import com.sikadwafastdaisfondturbo.pretloan.utils.gilde.ImageUtil
import org.json.JSONObject

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/4/19 12:02
 * @Annotation：意见反馈 - 联系方式列表
 */
class FeedbackImageAdapter(recyclerView: RecyclerView?): SikadwaRecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_feedback_image) {

    override fun setItemChildListener(helper: SikadwaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.imgDelete) //删除
        helper.setItemChildClickListener(R.id.imgView)//选择
    }

    override fun fillData(helper: SikadwaViewHolderHelper, position: Int, model: JSONObject) {
        val imgView = helper.getImageView(R.id.imgView)
        val imgDelete = helper.getImageView(R.id.imgDelete)

        //是否是默认图片
        val isDefault = model.optBoolean("isDefault",true)
        if (isDefault){
            imgView.setImageResource(R.mipmap.img_feedback_upload_image)
            imgDelete.visibility = View.INVISIBLE
        } else {
            ImageUtil.instance?.loadImageUrl(mContext,imgView,model.optString("imgPath"))
            imgDelete.visibility = View.VISIBLE
        }
    }
}